﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML.Graphics;
using SFML.Window;

namespace Theta.Components
{
    public class RenderableComponent : BaseComponent
    {
        public Vector2f Position
        {
            get {  return _sprite.Position; }
            set { _sprite.Position = value; }
        }

        public float Rotation
        {
            get { return _sprite.Rotation; }
            set { _sprite.Rotation = value; }
        }

        public Vector2f Scale
        {
            get { return _sprite.Scale; }
            set { _sprite.Scale = value; }
        }

        public Image Image
        {
            get { return _sprite.Image; }
            set { _sprite.Image = value; }
        }
        
        public IntRect SubRect
        {
            get { return _sprite.SubRect; }
            set { _sprite.SubRect = value; }
        }

        public Shader Shader { get; set; }

        Sprite _sprite;

        public RenderableComponent(Image texture, Vector2f position)
        {
            _sprite = new Sprite(texture);
            Position = position;
            Image = texture;
            Scale = new Vector2f(1, 1);
            Rotation = 0f;
        }

        public override void Draw(RenderWindow renderWindow)
        {
            if(Shader != null && Shader.IsAvailable)
                renderWindow.Draw(_sprite, Shader);
            else
                renderWindow.Draw(_sprite);
        }
    }
}